<? Phpr_View::beginBlock("head") ?>
	<script type="text/javascript" src="modules/blog/resources/javascript/edit.js"></script>
	<script type="text/javascript" src="modules/backend/resources/javascript/unload_manager.js"></script>
	<script type="text/javascript">
		UnloadManager.unload_message = 'The post has been changed. Unsaved data will be lost.';
	</script>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<ul class="breadcrumbs">
		<li><a href="<?= url('/blog/posts') ?>">Posts</a></li>
		<li><?= $this->app_page_title ?></li>
	</ul>
	
	<? if (!isset($fatalError)): ?>
		<? if (!($lock = Db_RecordLock::lock_exists($form_model))): ?>
			<div>
				<table class="layoutTable">
					<tr>
						<td>
							<?= Phpr_Form::openTag(array('id'=>'form_element')) ?>
								<? $this->formRender() ?>

								<?= backend_ajax_button('<u>S</u>ave', 'edit_onSave', array(), "prepareFunction: function(){phprTriggerSave();}, extraFields: {redirect: 0}, loadIndicator: {show: false}, onBeforePost: LightLoadingIndicator.show('Saving...'), onComplete: LightLoadingIndicator.hide, onSuccess: function(){UnloadManager.reset_changes()}, onAfterUpdate: setupInfoSize, onAfterError: setupInfoSize") ?>
								<?= backend_ajax_button('Save and Close', 'edit_onSave', array(), "prepareFunction: function(){phprTriggerSave();}, onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>
								<?= backend_ajax_button('Cancel', 'edit_onCancel', array(), "onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>
			
								<?= backend_ajax_button('Delete', 'edit_onDelete', array('class'=>"right"), "confirm: 'Do you really want to delete this post?', onBeforeScriptEval: function(){UnloadManager.reset_changes()}") ?>
								<div class="clear"></div>
							</form>
							<? $this->formAddLockCode() ?>
						</td>
						<td class="rightFixedColumn secondary_tabs">
							<? $this->renderPartial('sidebar') ?>
						</td>
					</tr>
				</table>
			</div>
		<? else: ?>
			<? $this->renderPartial(PATH_APP.'/modules/backend/controllers/partials/_record_locked.htm', array(
				'record_name'=>'post',
				'lock'=>$lock
			)) ?>
		<? endif ?>
	<? else: ?>
		<?= flash() ?>
		
		<p><a href="<?= url('/blog/posts') ?>">Return to the post list</a></p>
	<? endif ?>
<? Phpr_View::endBlock() ?>